<%-- 
    Document   : db1
    Created on : 2014/8/20, 上午 11:21:02
    Author     : Benny
--%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    Class.forName("com.mysql.jdbc.Driver");
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/javadb?zeroDateTimeBehavior=convertToNull","root","root");
    //Statement st=con.createStatement();
    String sql ="insert into person (username, tel, birthday) values (?,?,?)";
    java.sql.PreparedStatement ps =con.prepareStatement(sql);
    ps.setString(1, "Benny's Dog");
    ps.setString(2, "09-54317766");
    ps.setString(3, "1977/05/26");
    int x=ps.executeUpdate();
    /*int x=st.executeUpdate(sql);
    st.close();*/
    con.close();
    ps.close();
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>DB1</title>
    </head>
    <body>
        <h1>-----DB1-----</h1>
        <hr>
        共有<%= x %>筆資料
    </body>
</html>
